package com.dinzeer.resonantisshelomoh.se;


import com.dinzeer.legendreliclib.lib.util.slashblade.SlashBladeUtil;
import com.dinzeer.resonantisshelomoh.regsiter.RSSpecialEffectsRegistry;
import mods.flammpfeil.slashblade.registry.specialeffects.SpecialEffect;
import net.minecraft.world.damagesource.DamageTypes;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraftforge.event.entity.living.LivingHurtEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;

@Mod.EventBusSubscriber
public class SE37 extends SpecialEffect {
    public SE37() {
        super(37);
    }
    @SubscribeEvent
    public static void hurtEntityEvent(LivingHurtEvent event){
        LivingEntity target = event.getEntity();

        if (event.getSource().getEntity() instanceof Player player) {
            int level = player.experienceLevel;
            if(SlashBladeUtil.hasSpecialEffect(player.getMainHandItem(), RSSpecialEffectsRegistry.SeizetheBlood)){
                if (SpecialEffect.isEffective(RSSpecialEffectsRegistry.SeizetheBlood.get(), level)){
                    if (event.getSource().is(DamageTypes.PLAYER_ATTACK)){
                    event.setAmount((float) (event.getAmount()+target.getMaxHealth()*((float) 7 /1000)));
                    }
                }
            }
            if((SlashBladeUtil.hasSpecialEffect(player.getMainHandItem(), RSSpecialEffectsRegistry.HelplessRest))){
                if (SpecialEffect.isEffective(RSSpecialEffectsRegistry.HelplessRest.get(), level)){
                    if (!event.getSource().is(DamageTypes.PLAYER_ATTACK)){
                    event.setAmount((float) (event.getAmount()+target.getMaxHealth()*((float) 6 /1000)));
                    }
                }
            }
        }
    }
}
